Skip to content

Load session using cabal's --with-repl command #466

Merged
fendor merged 5 commits intohaskell:masterfrom
fendor:feature/cabal-with-repl
Jul 8, 2025
Merged

Load session using cabal's --with-repl command #466
fendor merged 5 commits intohaskell:masterfrom
fendor:feature/cabal-with-repl

Conversation

@fendor
Copy link
Collaborator

@fendor fendor commented Jun 17, 2025

This avoids quite a lot of hacky implementations to find the correct GHC
version, libdir and ghc-pkg location, as well as global package db
stuff.

There is a corner case which we need to handle:

cabal >= 3.15 && lib:Cabal <3.15

In other words, when a custom-setup imposes a restriction on the
lib:Cabal version, and this lib:Cabal version doesn't support the
--with-repl flag, then we can't use --with-repl.

We detect this by looking at the error message of the cabal command, it
looks roughly like this:

Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-with-custom-setup-0.1.0.0 (user goal)
[__1] next goal: cabal-with-custom-setup:setup.Cabal (dependency of cabal-with-custom-setup)
[__1] rejecting: cabal-with-custom-setup:setup.Cabal; 3.10.3.0/installed-3.10.3.0, ... (constraint from --with-repl requires >=3.15)
...

We check the error message for the existence of constraint from --with-repl requires >=3.15 and then fall back to using the old
approach which doesn't use response files or --with-repl flag.

Additionally, we extract a new Process module which contains helpers
for cradle actions.

closes #467

@fendor fendor force-pushed the feature/cabal-with-repl branch 2 times, most recently from 9a7930a to a472c08 Compare June 17, 2025 14:49
@fendor fendor force-pushed the feature/cabal-with-repl branch from a472c08 to 4d397da Compare June 17, 2025 14:57
@fendor fendor force-pushed the feature/cabal-with-repl branch 6 times, most recently from 7e539c5 to dc8e137 Compare July 4, 2025 13:20
@fendor fendor requested review from jhrcek, soulomoon and wz1000 and removed request for wz1000 July 4, 2025 13:20
Copy link
Collaborator

@mpickering mpickering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me in general, but I am not very familiar with this code and it changes many lines.

Is the approach load out somewhere in a Note? it would be good to precise explain at which cabal version this logic can be dropped.

fendor added 4 commits July 8, 2025 10:16
This avoids quite a lot of hacky implementations to find the correct GHC
version, libdir and ghc-pkg location, as well as global package db
stuff.

There is a corner case which we need to handle:

```
cabal >= 3.15 && lib:Cabal <3.15
```

In other words, when a custom-setup imposes a restriction on the
`lib:Cabal` version, and this `lib:Cabal` version doesn't support the
`--with-repl` flag, then we can't use `--with-repl`.

We detect this by looking at the error message of the cabal command, it
looks roughly like this:

    Error: [Cabal-7107]
    Could not resolve dependencies:
    [__0] trying: cabal-with-custom-setup-0.1.0.0 (user goal)
    [__1] next goal: cabal-with-custom-setup:setup.Cabal (dependency of cabal-with-custom-setup)
    [__1] rejecting: cabal-with-custom-setup:setup.Cabal; 3.10.3.0/installed-3.10.3.0, ... (constraint from --with-repl requires >=3.15)
    ...

We check the error message for the existence of `constraint from
--with-repl requires >=3.15` and then fall back to using the old
approach which doesn't use response files or `--with-repl` flag.

Additionally, we extract a new `Process` module which contains helpers
for cradle actions.
Cradle.hs grew a lot and is becoming to be unwieldy.
We fix this by extracting the most complicated cradle (cabal) into a
separate module.
To make this possible, we had to additionally extract a couple of types
and functions into separate modules as well to avoid cyclic module
dependencies.

This commit should not change any behaviour, but merely adds
documentation and moves definitions and data types.
@fendor fendor force-pushed the feature/cabal-with-repl branch from e312772 to e54869d Compare July 8, 2025 08:16
@fendor
Copy link
Collaborator Author

fendor commented Jul 8, 2025

I have added a note which explains the current approach in detail! Thank you for your review!

@fendor fendor merged commit 461b31d into haskell:master Jul 8, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cabal cradle needs to use --with-repl option

2 participants